from decimal import Decimal, ROUND_HALF_EVEN


def _fee(hours: int) -> Decimal:
    fee = Decimal(30)

    hours -= 9
    if hours <= 0:
        return fee

    factor1 = Decimal(5) / 2
    fee += factor1 * min(hours, 40)
    hours -= 40
    if hours <= 0:
        return fee

    factor2 = 2
    fee += factor2 * hours
    return min(fee, Decimal(150))


def quantize_money(value: Decimal, rounding=ROUND_HALF_EVEN):
    return value.quantize(Decimal("0.00"), rounding=rounding)


def _main():
    try:
        x = Decimal(input("请输入上网的时间（小时）："))
    except ValueError:
        print("输入有误，请检查。")
        return
    x = x.__ceil__()
    print(f"费用为 {quantize_money(_fee(x))} 元（不满一小时按一小时计）。")


if __name__ == "__main__":
    _main()
